package exam.demo20;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] arr = in.next().toCharArray();
        if(isA(arr)) {
            System.out.println(0);
            return;
        }
        if(isHui(arr)) {
            System.out.println(arr.length - 1);
        }else {
            System.out.println(arr.length);
        }
    }
    public static boolean isA(char[] arr) {
        char ch = arr[0];
        for(int i = 1; i < arr.length; i++) {
            if(arr[i] != ch) {
                return false;
            }
        }
        return true;
    }
    public static boolean isHui(char[] arr) {
        int len = arr.length;
        int mid = (len - 1) / 2;
        int left = 0;
        int right = 0;
        if (len % 2 == 0) {
            left = mid;
            right = mid + 1;
        } else {
            left = mid - 1;
            right = mid + 1;
        }
        while(left >= 0 && right < len) {
            if(arr[left] != arr[right]) {
                return false;
            }
            left--;
            right++;
        }
        return true;
    }
}
